package org.springboot.szsrcb;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
	private static final Logger log=LoggerFactory.getLogger(Application.class);
	
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
  /*
    @Bean
    public MultipartConfigElement multipartConfigElement(){
    	MultipartConfigFactory factory=new MultipartConfigFactory();
    	factory.setMaxFileSize("100MB");
    	factory.setMaxRequestSize("256KB");
		return factory.createMultipartConfig();
    	
    }
    */
    /*
    @Bean
    public CommonsMultipartResolver commonsMultipartResolver(){
    	CommonsMultipartResolver c=new CommonsMultipartResolver();
    	c.setDefaultEncoding("UTF-8");
    	c.setMaxUploadSize(5400000);
    	//c.setUploadTempDir("/");
		return null;
    	
    }
    */
   /*
    @Bean
    public CharacterEncodingFilter characterEncodingFilter(){
    	CharacterEncodingFilter filter =new CharacterEncodingFilter();
    	filter.setEncoding("UTF-8");
    	filter.setForceEncoding(true);
		return filter;
    	
    }*/
    /* 
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public void run(String... string )throws Exception{
    	log.info("Creating tables");
    	jdbcTemplate.execute("DROP TABLE users IF EXISTS");
    	jdbcTemplate.execute("CREATE TABLE users ("+
    			"id SERIAL,first_name VARCHAR(255),last_name VARCHAR(255)");
    	
        // Split up the array of whole names into an array of first/last names
        List<Object[]> splitUpNames = Arrays.asList("John Woo", "Jeff Dean", "Josh Bloch", "Josh Long").stream()
                .map(name -> name.split(" "))
                .collect(Collectors.toList());

        // Use a Java 8 stream to print out each tuple of the list
        splitUpNames.forEach(name -> log.info(String.format("Inserting customer record for %s %s", name[0], name[1])));

        // Uses JdbcTemplate's batchUpdate operation to bulk load data
        jdbcTemplate.batchUpdate("INSERT INTO customers(first_name, last_name) VALUES (?,?)", splitUpNames);

        log.info("Querying for customer records where first_name = 'Josh':");
        jdbcTemplate.query(
                "SELECT id, first_name, last_name FROM customers WHERE first_name = ?", new Object[] { "Josh" },
                (rs, rowNum) -> new User(rs.getLong("id"), rs.getString("first_name"), rs.getString("last_name"))
        ).forEach(customer -> log.info(customer.toString()));
    }
*/
}
